package com.easemob.server.example.comm.body;

import com.easemob.server.example.comm.wrapper.BodyWrapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;

public class ForbiddenBody implements BodyWrapper {

	 private String[] users;
	 
	 private Long duration;
	 

	  public ForbiddenBody(String[] users,Long duration) {
	      this.users = users;
	      this.duration = duration;
	  }

	  public String[] getUsers() {
	      return users;
	  }

	  public void setUsers(String[] users) {
	      this.users = users;
	  }

	  public Long getDuration() {
		return duration;
	}

	public void setDuration(Long duration) {
		this.duration = duration;
	}

	public ContainerNode<?> getBody() {
	      ObjectNode body = JsonNodeFactory.instance.objectNode();
	      ArrayNode names = JsonNodeFactory.instance.arrayNode();
	      body.put("usernames", names);
	      body.put("mute_duration", duration);

	      for (String user: users) {
	          names.add(user);
	      }

	      return body;
	  }

	    public Boolean validate() {
	        return null != users && users.length > 0 && duration != null;
	    }
}
